package com.company.project.web;
import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.model.TradeMqConsumerLog;
import com.company.project.service.TradeMqConsumerLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

/**
* Created by CodeGenerator on 2018/12/08.
*/
@ApiIgnore
@RestController
@RequestMapping("/trade/mq/consumer/log")
public class TradeMqConsumerLogController {
    @Resource
    private TradeMqConsumerLogService tradeMqConsumerLogService;

    @PostMapping("/add")
    public Result add(TradeMqConsumerLog tradeMqConsumerLog) {
        tradeMqConsumerLogService.save(tradeMqConsumerLog);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        tradeMqConsumerLogService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(TradeMqConsumerLog tradeMqConsumerLog) {
        tradeMqConsumerLogService.update(tradeMqConsumerLog);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    public Result detail(@RequestParam Integer id) {
        TradeMqConsumerLog tradeMqConsumerLog = tradeMqConsumerLogService.findById(id);
        return ResultGenerator.genSuccessResult(tradeMqConsumerLog);
    }

    @PostMapping("/list")
    public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size) {
        PageHelper.startPage(page, size);
        List<TradeMqConsumerLog> list = tradeMqConsumerLogService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

}
